package com.spring.cloud.examples.controller;

import com.spring.cloud.examples.vo.TestPostVo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 返回這個台服務器端口號等信息
 */
@RestController
@RequestMapping("/fileupload")
public class FileUploadController {



    @RequestMapping(value = "/upload",method= RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public String testPost(@RequestPart(value = "1.txt") MultipartFile file){
        System.out.println("receive "+file.getName());
        return "";
    }

    @RequestMapping(value = "/fileuploadAndSendObject",method= RequestMethod.POST,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public String fileuploadAndSendObject(TestPostVo testPostVo, @RequestParam("1.txt") MultipartFile file){
        System.out.println("receive "+file.getName());
        System.out.println("receive name "+testPostVo.getName());
        return "";
    }
}
